from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from ManageApp.models import UserInfo  # 请替换为你的实际模型路径

@csrf_exempt
def hint_user(request):
    keyword = request.GET.get("q", "")
    if keyword:
        queryset = UserInfo.objects.filter(name__icontains=keyword).values_list("name", flat=True)[:5]
        result = list(queryset)
    else:
        result = []
    return JsonResponse(result, safe=False)
